#include "GameUIWindow.h"
#include "GameWindowMgr.h"

extern CGameWindowMgr g_kWndMgr;


CGameUIWindow::CGameUIWindow(void)
{
	m_eWndType = WT_WINDOW;
	m_akLayout.clear();
}

CGameUIWindow::~CGameUIWindow(void)
{
	
}

bool CGameUIWindow::OnMsgBoxOk( const string& rkName,const string& rkInputText /*= ""*/ )
{
	return true;
}

bool CGameUIWindow::OnMsgBoxCancel( const string& rkName,const string& rkInputText /*= ""*/ )
{
	return true;
}

void CGameUIWindow::AddToLayout( const string& rkLayoutName,CGameControl* pkControl )
{
	if (pkControl == NULL)
	{
		return;
	}

	vector<CGameControl*>& rakChilds = m_akLayout[rkLayoutName];
	if (std::find(rakChilds.begin(),rakChilds.end(),pkControl) == rakChilds.end())
	{
		rakChilds.push_back(pkControl);
	}

	return;
}

void CGameUIWindow::DelFromLayout( const string& rkLayoutName,CGameControl* pkControl )
{
	if (pkControl == NULL)
	{
		return;
	}

	vector<CGameControl*>& rakChilds = m_akLayout[rkLayoutName];
	for (int i = 0;i < (int)rakChilds.size();i++)
	{
		if (rakChilds[i] == pkControl)
		{
			rakChilds.erase(rakChilds.begin() + i);
			break;
		}
	}

	return;
}

void CGameUIWindow::ShowLayout( const string& rkLayoutName )
{
	vector<CGameControl*>& rakChilds = m_akLayout[rkLayoutName];
	for (int i = 0;i < (int)rakChilds.size();i++)
	{
		rakChilds[i]->Show();
	}

	OnShowLayout(rkLayoutName);
	return;
}

void CGameUIWindow::HideLayout( const string& rkLayoutName )
{
	vector<CGameControl*>& rakChilds = m_akLayout[rkLayoutName];
	for (int i = 0;i < (int)rakChilds.size();i++)
	{
		rakChilds[i]->Hide();
	}

	OnHideLayout(rkLayoutName);
	return;
}

void CGameUIWindow::OnShowLayout( const string& rkLayoutName )
{
	return;
}

void CGameUIWindow::OnHideLayout( const string& rkLayoutName )
{
	return;
}